/**
 * editor_plugin_src.js
 *
 * Copyright 2012, 
 * Released under LGPL License.
 *
 * Author: Berkutov Y.V.
 */

(function() {
	// Load plugin specific language pack
	tinymce.PluginManager.requireLangPack('picasa_image');

	tinymce.create('tinymce.plugins.PicasaImage', {
		init : function(ed, url) {
			
			ed.addCommand('mcePicasaImage', function() {
				ed.windowManager.open({
					file : url + '/dialog.htm',
					width : 400 + ed.getLang('picasa_image.delta_width', 0), 
					height : 330 + ed.getLang('picasa_image.delta_height', 0), 
					inline : 1,
					resizable : "no",
					
				}, {
					plugin_url : url, // Plugin absolute URL
					some_custom_arg : 'custom arg', // Custom argument
					scrollbars : "yes"
				});
			});

			// Register PicasaImage button
			ed.addButton('picasa_image', {
				title : 'picasa_image.desc',
				cmd : 'mcePicasaImage',
				image : url + '/img/picasa_image.gif'
			});

			// Add a node change handler, selects the button in the UI when a image is selected
			ed.onNodeChange.add(function(ed, cm, n) {
				cm.setActive('picasa_image', n.nodeName == 'IMG');
			});
		},

		createControl : function(n, cm) {
			return null;
		},

		getInfo : function() {
			return {
				longname : 'PicasaImage plugin',
				author : 'Berkutov Y.V.',
				authorurl : 'http://will_be_later.com',
				infourl : '',
				version : "1.0"
			};
		}
	});

	// Register plugin
	tinymce.PluginManager.add('picasa_image', tinymce.plugins.PicasaImage);
})();